<%@page import="java.util.List"%>
<%@page import="edu.gatech.team404.Account"%>
<%@page import="edu.gatech.team404.Lab"%>
<%@page import="edu.gatech.team404.Team"%>
<%@page import="edu.gatech.team404.dal.LabDAL"%>
<%@page import="edu.gatech.team404.dal.TeamDAL"%>
<%@include file="header.jsp" %>

<div id="content">
    <%@include file="sidebar.jsp" %>
    
    <div id="main">
    	<%
    		final String courseName = request.getParameter("course");
    		final LabDAL lDal = new LabDAL();
    		final TeamDAL tDal = new TeamDAL();
    		List<Lab> labs = null;
    		
    		if (courseName != null) {
	    		labs = lDal.getAllLabsInCourse(courseName);   		
	    		lDal.close();
    		}
    	%>
    	<h1 align="center">
    		<%
    			if (courseName != null) {
    				out.print (courseName);
    			}
    			else {
    				out.print ("No report!");
    			}
    		
    		%>
    	</h1>
    	<p>
    		<%
    			if (courseName == null) {
    				out.print ("Please select one of the courses available on the left sidebar.");
    			}
    		
    			if (labs != null) {
		    		for (Lab lab : labs) {
		    			out.print("<h2 style=\"font-size:medium;\">" + lab.getName() + "</h2>");
		    			
		    			out.print("<ul>");
		    			List<Team> teams = tDal.getTeamsInLab(lab.getId());
		    			for (Team team : teams) {
		    				
			    			out.print("<li>" + team.getName() + "</li>");
			    			
			    			out.print("<ul>");
			    			List<Account> accts = team.getMembers();
			    			for (Account acct : accts) {
			    				out.print("<li>" + acct.getName() + "</li>");
			    			}
			    			out.print("</ul>");
		    			}
		    			out.print("</ul>");
		    		}
    			}
    			tDal.close();
    		%>
    	</p>
    </div>
</div>

<%@include file="footer.jsp" %>